//
//  ViewController.m
//  JAFDemo
//
//  Created by 阿飞 on 2018/1/24.
//  Copyright © 2018年 阿飞. All rights reserved.
//

#import "ViewController.h"
#import "JAFCalender.h"
#import "JAFButton.h"
#import "UIColor+Expanded.h"
#import "JMDropMenu.h"
@interface ViewController ()<JMDropMenuDelegate>


@property(nonatomic,strong)JAFCalender *calenderView;

@property(nonatomic,strong)JAFButton *leftButton;
/** titleArr */
@property (nonatomic, strong) NSArray *titleArr;
/** imgArr */
@property (nonatomic, strong) NSArray *imageArr;

@end
//获取屏幕 宽度、高度
#define SCREEN_WIDTH ([[UIScreen mainScreen] bounds].size.width)
#define SCREEN_HEIGHT ([[UIScreen mainScreen] bounds].size.height)
@implementation ViewController
-(void)viewWillAppear:(BOOL)animated{
    
    [super viewWillAppear:animated];
    
    self.navigationController.navigationBar.backgroundColor = [UIColor blueColor];
    
     self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(navRightClick)];

}
#pragma mark - 右边
- (void)navRightClick {
    [JMDropMenu showDropMenuFrame:CGRectMake(self.view.frame.size.width - 128, 64, 120, 89) ArrowOffset:102.f TitleArr:self.titleArr ImageArr:nil Type:JMDropMenuTypeQQ LayoutType:JMDropMenuLayoutTypeTitle RowHeight:40.f Delegate:self];
}


- (void)viewDidLoad {
    
    [super viewDidLoad];
    
    self.view.backgroundColor = [UIColor whiteColor];
    
     self.titleArr = @[@"按日期查询",@"按月份查询"];
     self.imageArr = @[@"img1",@"img2"];

    [self setDataWithType:0 WithLeftTitle:@"前一天" withRightTitle:@"后一天"];
    
    
}

-(void)setDataWithType:(NSInteger)type WithLeftTitle:(NSString *)leftTitle withRightTitle:(NSString *)rightTitle{
    
    self.calenderView = [[JAFCalender alloc]initWithFrame:CGRectMake(0, 64, SCREEN_WIDTH, SCREEN_HEIGHT*400/667)withSearch:type withLeftTitle:leftTitle withRightTitle:rightTitle];
    self.calenderView.currentMonthTitleColor =[UIColor hexStringToColor:@"2c2c2c"];
   // calenderView.lastMonthTitleColor =[UIColor hexStringToColor:@"8a8a8a"];
    //calenderView.nextMonthTitleColor =[UIColor hexStringToColor:@"8a8a8a"];
    
    self.calenderView.isHaveAnimation = YES;
    
    self.calenderView.isCanScroll = YES;
    
    self.calenderView.isShowLastAndNextBtn = YES;
    
    self.calenderView.todayTitleColor =[UIColor redColor];
    
    self.calenderView.selectBackColor =[UIColor redColor];
    
    self.calenderView.isShowLastAndNextDate = NO;
    
    [self.calenderView dealData];
    self.calenderView.viewController = self;
    [self.view addSubview:self.calenderView];
    
    self.calenderView.selectBlock = ^(NSInteger year, NSInteger month, NSInteger day) {
        
        NSLog(@"啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊%ld年 - %ld月 - %ld日",year,month,day);
        
        
    };
}
- (void)didSelectRowAtIndex:(NSInteger)index Title:(NSString *)title Image:(NSString *)image
{
    
    NSLog(@"index----%zd,  title---%@, image---%@", index, title, image);
    
    if (index==0) {
       [self.calenderView removeFromSuperview];
      [self setDataWithType:0  WithLeftTitle:@"前一天" withRightTitle:@"后一天"];
        
    }else{
       [self.calenderView removeFromSuperview];
      [self setDataWithType:1 WithLeftTitle:@"前一月" withRightTitle:@"后一月"];
    }
    
  
}




@end
